package com.jz.community.moduleshoppingguide.home.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.home.bean.PreferentialBean;
import com.jz.community.moduleshoppingguide.home.model.ShoppingGuideModel;
import com.jz.community.moduleshoppingguide.home.model.ShoppingModelGuideImpl;
import com.jz.community.moduleshoppingguide.home.ui.PreferentialView;

public class PreferentialPresenter extends BaseLifeCyclePresent<PreferentialView.View> implements PreferentialView.Presenter {

    private ShoppingGuideModel shoppingModel;
    private PreferentialView.View mView;

    public PreferentialPresenter(PreferentialView.View mView) {
        this.mView = mView;
        shoppingModel = new ShoppingModelGuideImpl(mView.getContext());
    }

    @Override
    public void getPreferential(int page, int size, String cityCode, String message, int type) {
        shoppingModel.preferentialArea(page, size, cityCode, message, new OnLoadListener<PreferentialBean>() {
            @Override
            public void onSuccess(PreferentialBean preferentialBean) {
                mView.showPreferential(preferentialBean, type);
            }

            @Override
            public void onFail(String msg, int code) {
                mView.onFail(msg);
            }
        });
    }
}
